package com.zbl.zblproject.erp.service.impl;

import com.zbl.zblproject.erp.entity.ErpCategory;
import com.zbl.zblproject.erp.mapper.ErpCategoryMapper;
import com.zbl.zblproject.erp.service.ErpCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/9
 */
@Service
@Transactional
public class ErpCategoryServiceImpl implements ErpCategoryService {


    @Autowired
    private ErpCategoryMapper erpCategoryMapper;

    @Override
    @Cacheable(value = "app", key = "'categories'", sync = true)
    public List<ErpCategory> categories() {
        List<ErpCategory> categories = erpCategoryMapper.selectFather();
        return categories;
    }

    @Override
    public List<ErpCategory> categories(int parentId) {
        List<ErpCategory> categories = erpCategoryMapper.selectCategory(parentId);
        return categories;
    }

    @Override
    public List<ErpCategory> list() {
        return erpCategoryMapper.selectList(null);
    }
}
